<?php
	include "includes".DIRECTORY_SEPARATOR."start_session.php";
	//include "javascript".DIRECTORY_SEPARATOR."serverside.php";
	
	if ( !defined('USERNAME') || !defined('GROUP') || GROUP != "admin" )
	{
		header("Location: manage_login.php");
		exit;
	}

	$countiesAndIdsQuery1 = getAllCountiesAndIds($dbc);
	while($countyRetrv1 = mysqli_fetch_assoc($countiesAndIdsQuery1)){
			$localCounties1[$countyRetrv1["id"]] = $countyRetrv1["name"];
			//echo $countyRetrv1["id"]."\n";
	}
	 $rez = mysqli_query($dbc,"SELECT * FROM utilizatori");

	echo "<br />";
	echo "<table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\" align=\"center\">";


		echo"<tr>";
			echo"<td>";
				echo "<b><font color=\"#0000FF\">Nr.</b></font>";
			echo"</td>";
			echo"<td>";
				echo "<b><font color=\"#0000FF\">Nume</b></font>";
			echo"</td>";
			echo"<td>";
				echo "<b><font color=\"#0000FF\">Parola</b></font>";
			echo"</td>";
			echo"<td>";
				echo "<b><font color=\"#0000FF\">Email</b></font>";
			echo"</td>";
			echo"<td>";
				echo "<b><font color=\"#0000FF\">Grup</b></font>";
			echo"</td>";
			echo"<td colspan='2'>";
				echo "<b><font color=\"#0000FF\">Judete asociate</b></font>";
			echo"</td>";
		echo"</tr>";


	$count = 0;
	while($rand = mysqli_fetch_row($rez))
	{
		$count = $count + 1;
		echo"<tr>";
			echo"<td>";
				echo "<b>".$count."</b>";
			echo"</td>";
			echo"<td>";
				echo "<b>".$rand[1]."</b>";
			echo"</td>";
			echo"<td>";
				echo "<b>".$rand[2]."</b>";
			echo"</td>";
			echo"<td>";
				echo "<b>".$rand[3]."</b>";
			echo"</td>";
			echo"<td colspan='2'>";
				echo "<b>".$rand[4]."</b>";
			echo"</td>";
			
			
			$countiesIds1 = explode(",",$rand[5]);
			
			echo"<td>";
			if (isset($countiesIds1)  && !empty($countiesIds1) ){
				foreach($countiesIds1 as $countyId1)
					if ($countyId1 != "" && $countyId1 != " ")
						echo "<b>".$localCounties1[$countyId1]."\n</b>";
			}
			echo"</td>";
			echo"<td>";
				echo "<a href=\"admin_remove_user.php?mail=".$rand[3]."\"><font color=\"#CC0000\">sterge</a>";
			echo"</td>";
			
		echo"</tr>";

	}
	echo "</table>";
?>